package servlet;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;


public class MockClient {
	public static void main(String[] args) throws UnknownHostException, IOException {
		String ip ="127.0.0.1"; 
		Socket s = new Socket(ip,8080);
		PrintStream out = new PrintStream(s.getOutputStream());
		out.println("GET /美女.jpg HTTP/1.1");
		out.println("Host: localhost:8080");
		out.println();
		out.flush();
		
		FileOutputStream fout = new FileOutputStream(new File("/home/tarena/Desktop/1.jpg"));
		
		InputStream in = s.getInputStream();
		int b ;
		while((b=in.read())!=-1){
			fout.write(b);
			fout.flush();
			System.out.print((char)b);
		}
		fout.close();
	}
}
